export default{
	install (Vue) {
		Vue.directive('ofshow', {
			bind(el, binding, vnode){
	            overFlow(el, binding, vnode)
			},
			update(el, binding, vnode){
				overFlow(el, binding, vnode)
			}
		})
	}
}

function overFlow(el, binding, vnode) {
	var $me = $(el), $child = $me.find(`.${binding.value}`);
        $me.on('mousewheel DOMMouseScroll',function(e){
                // 阻止默认行为
                var e = e || window.event;
                 e.preventDefault();

                 var delta = (e.originalEvent.wheelDelta && (e.originalEvent.wheelDelta > 0 ? 1 : -1)) ||  // chrome & ie
                (e.originalEvent.detail && (e.originalEvent.detail > 0 ? -1 : 1));              // firefox

                 // 获取基本参数
                 var w = $me.width(),
                    _cW = $child.outerWidth() * $child.length,
                    clientW = _cW - w,
                    btnOff= true,
                    step = 500,
                    scroollL = $me.scrollLeft();
                  // 判断鼠标滚动方向
                  if(delta > 0){
                    scroollL -= step; 
                  }else if(delta < 0 ){
                    scroollL += step;
                  }

                  // 赋值
                  $me.stop().animate({scrollLeft:scroollL},300)
              })
}
